package com.heima.admin.controller.v1;


import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理",tags = "敏感词管理")
public class AdSensitiveController {

    @Autowired
    private AdSensitiveService adSensitiveService;

    //添加敏感词
    @ApiOperation("添加敏感词")
    @PostMapping("/save")
    public ResponseResult add(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.addSensitiveWord(adSensitive);
    }

    //分页查询
    @ApiOperation("分页查询敏感词")
    @PostMapping("/list")
    public ResponseResult findByPage(@RequestBody SensitiveDto dto){
        return adSensitiveService.findByPage(dto);
    }

    //修改
    @ApiOperation("修改敏感词")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.update2(adSensitive);
    }

    //删除
    @ApiOperation("删除敏感词")
    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        return adSensitiveService.delete2(id);
    }
}
